/**
 * futures : masterlink.futures.controller.IndexController.java
 */
package masterlink.futures.controller;

import javax.servlet.http.HttpServletRequest;

import masterlink.futures.dao.VolatilityDao;
import masterlink.futures.util.WebUtils;
import masterlink.futures.vo.Employee;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import baytony.util.Util;

/**
 * TODO Write the description
 *
 * @author : tonyyang
 * Create date : 2011/9/30
 * @version 1.0.0	
 */
@Controller
@RequestMapping(value = "/volatility")
public class VolatilityController extends BasicController{

	@Autowired
	private VolatilityDao volatilityDao;
	
	@RequestMapping(method=RequestMethod.GET)
	@Override
	public String index(HttpServletRequest req){
		Employee emp=WebUtils.getLogEmployee(req);
		log.trace("Employee {} in /volatility loading volatility data.",emp);
		req.setAttribute("VolatilityComm", volatilityDao.findByComm("FITX"));
		req.setAttribute("type", "FITX");
		return "data/volatility";
	}
	
	
	@RequestMapping(method=RequestMethod.POST)
	public String index(@RequestParam("type")String type,HttpServletRequest req){
		Employee emp=WebUtils.getLogEmployee(req);
		log.trace("Employee {} in /volatility loading volatility data for type : {}",emp,type);
		if(Util.isEmptyString(type)){
			type="FITX";
		}
		req.setAttribute("VolatilityComm", volatilityDao.findByComm(type));
		req.setAttribute("type", type);
		return "data/volatility";
	}
}
